//代理
export default {
  //获取完成后的列表的函数
  finishedTodos(state) {
    return state.todos.filter((todo) => todo.isFinished);
  },
  unfinishedTodos(state) {
    return state.todos.filter((todo) => !todo.isFinished);
  },
  //改变getter会重新计算 根据state.filter数据，它一旦变更就会代理触发以下分支函数
  filteredTodos(state, getters) {
    switch (state.filter) {
      case 'finished':
        return getters.finishedTodos;
      case 'unfinished':
        return getters.unfinishedTodos;
      default:
        return state.todos;
    }
  }
};
